

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/myblog/img/fluid.png">
  <link rel="icon" href="/myblog/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="ZTY">
  <meta name="keywords" content="">
  
    <meta name="description" content="这是我参与「第三届青训营 -后端场」笔记创作活动的第2篇笔记。">
<meta property="og:type" content="article">
<meta property="og:title" content="Golang学习&amp;高质量编程和性能调优 ｜ 青训营笔记02">
<meta property="og:url" content="https://zty-f.gitee.io/myblog/2022/05/16/Golang%E5%AD%A6%E4%B9%A0-%E9%AB%98%E8%B4%A8%E9%87%8F%E7%BC%96%E7%A8%8B%E5%92%8C%E6%80%A7%E8%83%BD%E8%B0%83%E4%BC%98-%EF%BD%9C-%E9%9D%92%E8%AE%AD%E8%90%A5%E7%AC%94%E8%AE%B002/index.html">
<meta property="og:site_name" content="zty-f">
<meta property="og:description" content="这是我参与「第三届青训营 -后端场」笔记创作活动的第2篇笔记。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://s3.bmp.ovh/imgs/2022/05/08/f23f4d4f7aa46d74.png">
<meta property="article:published_time" content="2022-05-16T09:19:43.000Z">
<meta property="article:modified_time" content="2024-12-28T02:09:42.874Z">
<meta property="article:author" content="ZTY">
<meta property="article:tag" content="Go">
<meta property="article:tag" content="青训营">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://s3.bmp.ovh/imgs/2022/05/08/f23f4d4f7aa46d74.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>Golang学习&amp;高质量编程和性能调优 ｜ 青训营笔记02 - zty-f</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/myblog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/myblog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/myblog/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="//at.alicdn.com/t/c/font_3799348_11m20qbqwhmo.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"zty-f.gitee.io","root":"/myblog/","version":"1.9.3","typing":{"enable":true,"typeSpeed":150,"cursorChar":"_","loop":true,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/myblog/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/myblog/js/utils.js" ></script>
  <script  src="/myblog/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/myblog/">
      <strong>思前想后</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" target="_self" href="javascript:;" role="button"
                 data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="iconfont icon-books"></i>
                魔盒
              </a>
              <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                
                  
                  
                  
                  <a class="dropdown-item" href="/myblog/archives/">
                    <i class="iconfont icon-archive-fill"></i>
                    归档
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/myblog/categories/">
                    <i class="iconfont icon-yingyong"></i>
                    分类
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/myblog/tags/">
                    <i class="iconfont icon-tags-fill"></i>
                    标签
                  </a>
                
              </div>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/links/">
                <i class="iconfont icon-link-fill"></i>
                友链
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" target="_blank" rel="noopener" href="https://github.com/zty-f">
                <i class="iconfont icon-GitHub"></i>
                
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/myblog/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="Golang学习&amp;高质量编程和性能调优 ｜ 青训营笔记02"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        ZTY
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-05-16 17:19" pubdate>
          2022年5月16日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          2.2k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          18 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">Golang学习&amp;高质量编程和性能调优 ｜ 青训营笔记02</h1>
            
            
              <div class="markdown-body">
                
                <h2 id="高质量编程和性能调优"><a href="#高质量编程和性能调优" class="headerlink" title="高质量编程和性能调优"></a>高质量编程和性能调优</h2><h4 id="1-高质量编程通用原则"><a href="#1-高质量编程通用原则" class="headerlink" title="1.高质量编程通用原则"></a>1.高质量编程通用原则</h4><ul>
<li><p>简单性<br>消除”多余的复杂性”，以简单清晰的逻辑编写代码。<br>在实际工程项目中，复杂的程序逻辑会让人害怕重构和优化，因为无法明确预知调整造成的影响范围难以理解的逻辑，排查问题时也难以定位，不知道如何修复。</p>
</li>
<li><p>可读性<br>可读性很重要，因为代码是写给人看的，而不是机器。<br>在项目不断迭代的过程中，大部分工作是对已有功能的完善或扩展，很少会完全下线某个功能，对应的功能代码实际会生存很长时间。已上线的代码在其生命周期内会被不同的人阅读几十上百次。</p>
<p>听课时老师经常说的在课堂上不遵守纪律影响全班同学的时间，难以理解的代码会占用后续每一个程序员的时间。</p>
</li>
<li><p>生产力<br>编程在当前更多是团队合作，因此团队整体的工作效率是非常重要的一方面。<br>为了降低新成员上手项目代码的成本，Go语言甚至通过工具强制统一所有代码格式。<br>编码在整个项目开发链路中的一个节点，遵循规范，避免常见缺陷的代码能够降低后续联调、测试、验证、上线等各个节点的出现问题的概率，就算出现问题也能快速排查定位。</p>
</li>
</ul>
<h4 id="2-go语言编码规范"><a href="#2-go语言编码规范" class="headerlink" title="2.go语言编码规范"></a>2.go语言编码规范</h4><ul>
<li>gofmt工具</li>
</ul>
<p>Go语言官方提供的工具，能自动格式化Go 语言代码为官方统─风格常见IDE都支持方便的配置</p>
<ul>
<li>goimports工具</li>
</ul>
<p>也是Go语言官方提供的工具<br>实际等于gofmt加上依赖包管理<br>自动增删依赖的包引用、将依赖包按字母序排序并分类</p>
<h4 id="3-注释原则和Java大同小异！"><a href="#3-注释原则和Java大同小异！" class="headerlink" title="3.注释原则和Java大同小异！"></a>3.注释原则和Java大同小异！</h4><ul>
<li>代码是最好的注释。</li>
<li>注释应该提供代码未表达出的上下文信息。</li>
<li>简洁清晰的代码对流程注释没有要求，但是对于为什么这么做，代码的相关背景，可以通过注释补充，提供有效信息，在以后工作学习中可以慢体会。</li>
</ul>
<h4 id="4-命名规范和Java有所不同"><a href="#4-命名规范和Java有所不同" class="headerlink" title="4.命名规范和Java有所不同"></a>4.命名规范和Java有所不同</h4><ul>
<li><h5 id="变量"><a href="#变量" class="headerlink" title="变量"></a>变量</h5></li>
</ul>
<p><img src="https://s3.bmp.ovh/imgs/2022/05/16/0c0de76214479774.png" srcset="/myblog/img/loading.gif" lazyload></p>
<ul>
<li><h5 id="方法"><a href="#方法" class="headerlink" title="方法"></a>方法</h5></li>
</ul>
<p><img src="https://s3.bmp.ovh/imgs/2022/05/16/e3d3e4d82fb0d54d.png" srcset="/myblog/img/loading.gif" lazyload></p>
<ul>
<li><h5 id="package"><a href="#package" class="headerlink" title="package"></a>package</h5></li>
</ul>
<p><img src="https://s3.bmp.ovh/imgs/2022/05/16/a7925a4b1ccda576.png" srcset="/myblog/img/loading.gif" lazyload></p>
<h4 id="5-错误和异常处理"><a href="#5-错误和异常处理" class="headerlink" title="5.错误和异常处理"></a>5.错误和异常处理</h4><ul>
<li><h5 id="简单错误"><a href="#简单错误" class="headerlink" title="简单错误"></a>简单错误</h5><ul>
<li>简单的错误指的是仅出现一次的错误，且在其他地方不需要捕获该错误</li>
<li>优先使用crrors.New来创建匿名变量来直接表示简单错误</li>
<li>如果有格式化的需求，使用fmt.Errorf</li>
</ul>
</li>
<li><h5 id="复杂错误"><a href="#复杂错误" class="headerlink" title="复杂错误"></a>复杂错误</h5></li>
</ul>
<p>对于复杂的错误，有时候并不能简单描述，应该如何处理?<br>错误的包装提供了一个error嵌套另一个error的能力，生成一个error的跟踪链，同时结合错误的判定方法来确认调用链中是否有关注的错误出现。这个能力的好处是每一层调用方可以补充自己对应的上下文，方便跟踪排查问题，确定问题的根本原因在哪里。<br>在fmt.Errorf中使用: %w关键字来将—个错误wrap至其错误链中。</p>
<ul>
<li><h5 id="错误判定"><a href="#错误判定" class="headerlink" title="错误判定"></a>错误判定</h5><ul>
<li>判定一个错误是否为特定错误，使用errors.Is。</li>
<li>不同于使用&#x3D;&#x3D;，使用该方法可以判定错误链上的所有错误是否含有特定的错误。</li>
<li>在错误链上获取特定种类的错误,使用crrors.As。</li>
</ul>
</li>
<li><p>在Go中，比错误更严重的就是panic，它的出现表示程序无法正常工作了，那么在使用时应该注意什么呢?<br>不建议在业务代码中使用panic。因为panic发生后，会向上传播至调用栈顶，如果当前goroutine中所有deferred函数都不包含recover就会造成整个程序崩溃。</p>
</li>
<li><p>若问题可以被屏蔽或解决，建议使用error代替panic。</p>
</li>
<li><p>特殊地，当程序启动阶段发生不可逆转的错误时，可以在init或main函数中使用panic。因为在这种情况下，服务启动起来也不会有意义比如示例是启动消息队列监听器的逻辑，在创建消费组失败的时候会Panicf，实际打印日志，然后抛出panic。</p>
</li>
<li><h5 id="recover"><a href="#recover" class="headerlink" title="recover"></a>recover</h5><ul>
<li>recover只能在被defer的函数中使用</li>
<li>嵌套无法生效</li>
<li>只在当前goroutine生效-</li>
<li>defer的语句是后进先出</li>
</ul>
</li>
</ul>
<h4 id="6-性能优化"><a href="#6-性能优化" class="headerlink" title="6.性能优化"></a>6.性能优化</h4><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs go"><span class="hljs-comment">//基准测试命令</span><br><span class="hljs-keyword">go</span> test -bench=.   <span class="hljs-comment">// . 代表测试所有文件，可以单独一个go文件也可以</span><br><span class="hljs-keyword">go</span> test -bench=. -benchmem <span class="hljs-comment">//-benchmem 表示也统计内存信息</span><br></code></pre></td></tr></table></figure>

<h4 id="7-性能优化工具pprof"><a href="#7-性能优化工具pprof" class="headerlink" title="7.性能优化工具pprof"></a>7.性能优化工具pprof</h4><h5 id="注意：浏览器不能正常显示需要安装graphviz组件"><a href="#注意：浏览器不能正常显示需要安装graphviz组件" class="headerlink" title="注意：浏览器不能正常显示需要安装graphviz组件"></a>注意：浏览器不能正常显示需要安装graphviz组件</h5><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><code class="hljs go">浏览器中打开http:<span class="hljs-comment">//localhost:6060/debug/pprof</span><br><br>allocs:内存分配情况<br>blocks:阻塞操作情况<br>cmdline:程序启动命令及<br>goroutine:当前所有<br>goroutine的堆栈信息<br>heap:堆上内存使用情况(同alloc)<br>mutex:锁竞争操作情况<br>profile: CPU占用情况<br>threadcreate:当前所有创建的系统线程的堆栈信息<br>trace:程序运行跟踪信息<br>    <br>使用命令：<span class="hljs-keyword">go</span> tool pprof <span class="hljs-string">&quot;http://localhost:6060/debug/pprof/profile?seconds=10&quot;</span> 启动采样数据<br><br>使用 topN 命令查看资源占用最高的函数<br><br>例如，输入top5，查看CPU占用最高的<span class="hljs-number">5</span>个函数这五列从左到右分别是:<br>Flat:当前函数的占用<br>Flat%:Flat占总量的比例<br>Sum%:上面所有行的Flat%总和<br>Cum (Cumulative):当前函数加上其调用函数的总占用<br>Cum%: Cum占总量的比例<br><br>输入list + 函数名称 查找这个函数，看看具体是哪里出了问题<br>List命令会根据后面给定的正则表达式查找代码，并按行展示出每一行的占用。<br><br>除了这两种视图之外，我们还可以输入web命令，生成一张调用关系图，默认会使用浏览器打开。<br></code></pre></td></tr></table></figure>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/myblog/categories/Golang/" class="category-chain-item">Golang</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/myblog/tags/Go/">#Go</a>
      
        <a href="/myblog/tags/%E9%9D%92%E8%AE%AD%E8%90%A5/">#青训营</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>Golang学习&amp;高质量编程和性能调优 ｜ 青训营笔记02</div>
      <div>https://zty-f.gitee.io/myblog/2022/05/16/Golang学习-高质量编程和性能调优-｜-青训营笔记02/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>ZTY</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年5月16日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2024年12月28日</div>
        </div>
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/myblog/2022/05/17/Golang%E5%AD%A6%E4%B9%A0-%E9%AB%98%E6%80%A7%E8%83%BDGo%E8%AF%AD%E8%A8%80%E5%8F%91%E8%A1%8C%E7%89%88%E4%BC%98%E5%8C%96-%EF%BD%9C-%E9%9D%92%E8%AE%AD%E8%90%A5%E7%AC%94%E8%AE%B003/" title="Golang学习&amp;高性能Go语言发行版优化 ｜ 青训营笔记03">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Golang学习&amp;高性能Go语言发行版优化 ｜ 青训营笔记03</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/myblog/2022/05/12/%E5%B0%8F%E5%8E%82%E9%9D%A2%E8%AF%95%E8%AE%B0%E5%BD%95-003/" title="小厂实习面试记录-003">
                        <span class="hidden-mobile">小厂实习面试记录-003</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  <article id="comments" lazyload>
    
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"wLiqWYFHh2NEnXVcULmB4KWQ-gzGzoHsz","appKey":"GSfJMcM0GcCzp1HDNXJfd9Bt","path":"window.location.pathname","placeholder":"欢迎大家积极评论~  支持Markdown格式~","avatar":"wavatar","meta":["nick","mail","link"],"requiredFields":["nick","mail"],"pageSize":10,"lang":"zh-CN","highlight":true,"recordIP":true,"serverURLs":"https://wliqwyfh.lc-cn-n1-shared.com","emojiCDN":null,"emojiMaps":null,"enableQQ":true},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


  </article>


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
      <div class="col-lg-7 mx-auto nopadding-x-md">
        <div class="container custom mx-auto">
          <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"> <script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/meting@2.0.1/dist/Meting.min.js"></script> <meting-js server="netease"  type="playlist"  id="7708362143" fixed="true"  mini="true" order="list" loop="all" preload="auto" list-folded="true" autoplay="true" theme="red"> </meting-js>
        </div>
      </div>
    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://github.com/zty-f" target="_blank" rel="nofollow noopener"><span>Copyright &copy;</span></a> <a href="http://www.zty-f.fun/" target="_blank" rel="nofollow noopener"><span>zty-f</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
    <!-- 备案信息 ICP for China -->
    <div class="beian">
  <span>
    <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">
      蜀ICP备2022002077号-1
    </a>
  </span>
  
</div>

  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/myblog/js/events.js" ></script>
<script  src="/myblog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/myblog/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/myblog/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/myblog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
